'''
判断一个ip字符串被去掉了点可以组成多少个IP地址，如果组成不了返回0
19216801
'''
def func(str,index,level,res):
    #所有满足的对象
    if level==5 or index==len(str)-1:
        #只满足是ip地址的
        if level==5 and index==len(str)-1:
            print(".".join(res))
        return
    for i in  range(1,4):
        substr = str[index+1:index+1+i]
        if int(substr)<256 and (substr=="0" or not substr.startswith("0")):
            res.append(substr)
            func(str,index+i,level+1,res)
            res.pop()
if __name__ == '__main__':
    s = "19216801"
    index = -1
    level = 1
    res = []
    func(s,index,level,res)